#include <vector>

using namespace std;

class Solution
{
public:
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2)
    {
        vector<int> hash(1001);

        for (int i = 0; i < nums1.size(); i++)
            for (int j = 0; j < nums2.size(); j++)
                if (nums1[i] == nums2[j])
                    hash[nums1[i]]++;

        vector<int> ret;
        for (int i = 0; i < hash.size(); i++)
            if (hash[i] != 0)
                ret.push_back(hash[i]);

        return ret;
    }

};